package com.share.device.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.share.device.domain.Role;
import com.share.device.domain.Staff;
import com.share.device.domain.dto.StaffDto;
import com.share.device.domain.vo.StaffVo;
import com.share.device.mapper.StaffMapper;
import com.share.device.service.StaffService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StaffServiceImpl extends ServiceImpl<StaffMapper,Staff> implements StaffService {
    @Autowired
    private StaffMapper staffMapper;
    @Override
    public PageInfo<StaffVo> getStaffList(StaffDto staffDto) {
        if(ObjectUtils.isEmpty(staffDto)){
            throw new RuntimeException("分页参数不能为空");
        }
        PageHelper.startPage(staffDto.getPageNum(),staffDto.getPageSize());
       List<StaffVo> staffVoList = staffMapper.getStaffList(staffDto);
        PageInfo<StaffVo> pageInfo = new PageInfo<>(staffVoList);
        return pageInfo;
    }

    //角色下拉框
    @Override
    public List<Role> getRoleList() {
       List<Role> roleList = staffMapper.getRoleList();
        return roleList;
    }
}
